﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ScheduleManagement.UI
{
    public partial class frm_ClosePoint : Form
    {
        private int Flag = 0;
        public frm_ClosePoint()
        {
            InitializeComponent();
        }

        
        private void ClosePoint_Load(object sender, EventArgs e)
        {
            this.MaximizeBox = false;
            this.MinimizeBox = false;
        }

        /// <summary>
        /// 确定退出按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (rdoExit.Checked)
            {
                Flag = 1;
            }
            else
            {
                Flag = 2;
            }
            this.Close();
        }

        /// <summary>
        /// 取消按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNO_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frm_ClosePoint_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (Flag == 1)
            {
                this.DialogResult = DialogResult.Cancel;//如果选择直接退出，关闭整个程序
            }
            else if (Flag == 2)
            {
                //选择最小化到系统托盘处，最小化窗口
                frm_Main.Instance.WindowState = FormWindowState.Minimized;
                frm_Main.Instance.notifyIcon1.Visible = true;
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                this.DialogResult = DialogResult.OK;
            }
        }
    }
}